package cn.bjc.service.impl;

import cn.bjc.domain.Product;
import cn.bjc.mapper.ProductMapper;
import cn.bjc.service.IProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.Map;

@Service
public class ProductServiceImpl implements IProductService {
    
    @Autowired
    private ProductMapper productMapper;


    @Override
    public Product getById(Long id) {
        return productMapper.getById(id);
    }

    @Override
    public Map<String, Object> add(Product product) {
        productMapper.add(product);

        HashMap<String, Object> map = new HashMap<>();
        map.put("success",true);
        map.put("message","添加成功");

        return map;
    }

    @Override
    public Map<String, Object> update(Product product) {
        productMapper.update(product);
        
        HashMap<String, Object> map = new HashMap<>();
        map.put("success",true);
        map.put("message","修改成功");

        return map;
    }
}
